/*
 * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
 * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 */

package javax.annotation;

import java.lang.annotation.*;
import static java.lang.annotation.ElementType.*;
import static java.lang.annotation.RetentionPolicy.*;

/**
 * The PostConstruct annotation is used on a method that needs to be executed
 * after dependency injection is done to perform any initialization. This
 * method MUST be invoked before the class is put into service. This
 * annotation MUST be supported on all classes that support dependency
 * injection. The method annotated with PostConstruct MUST be invoked even
 * if the class does not request any resources to be injected. Only one
 * method can be annotated with this annotation. The method on which the
 * PostConstruct annotation is applied MUST fulfill all of the following
 * criteria:
 * <p>
 * <ul>
 * <li>The method MUST NOT have any parameters except in the case of
 * interceptors in which case it takes an InvocationContext object as
 * defined by the Interceptors specification.</li>
 * <li>The method defined on an interceptor class MUST HAVE one of the
 * following signatures:
 * <p>
 * void &#060;METHOD&#062;(InvocationContext)
 * <p>
 * Object &#060;METHOD&#062;(InvocationContext) throws Exception
 * <p>
 * <i>Note: A PostConstruct interceptor method must not throw application
 * exceptions, but it may be declared to throw checked exceptions including
 * the java.lang.Exception if the same interceptor method interposes on
 * business or timeout methods in addition to lifecycle events. If a
 * PostConstruct interceptor method returns a value, it is ignored by
 * the container.</i>
 * </li>
 * <li>The method defined on a non-interceptor class MUST HAVE the
 * following signature:
 * <p>
 * void &#060;METHOD&#062;()
 * </li>
 * <li>The method on which PostConstruct is applied MAY be public, protected,
 * package private or private.</li>
 * <li>The method MUST NOT be static except for the application client.</li>
 * <li>The method MAY be final.</li>
 * <li>If the method throws an unchecked exception the class MUST NOT be put into
 * service except in the case of EJBs where the EJB can handle exceptions and
 * even recover from them.</li></ul>
 * @since Common Annotations 1.0
 * @see javax.annotation.PreDestroy
 * @see javax.annotation.Resource
 */
// PostConstruct注释用于需要在依赖注入完成后执行任何初始化的方法上。
// 在将类放入服务之前必须调用此方法。
// 所有支持依赖注入的类都必须支持该注释。
// 即使类没有请求注入任何资源，使用PostConstruct注释的方法也必须被调用。
// 只能用这个注释注释一个方法。
// 应用PostConstruct注释的方法必须满足以下所有条件:
// 该方法不能有任何参数，除非是拦截器，在这种情况下，它接受一个由拦截器规范定义的InvocationContext对象。
// 在拦截器类上定义的方法必须具有以下签名之一: 空白法> (InvocationContext) 对象   (InvocationContext)抛出异常
// 注意:PostConstruct拦截器方法不能抛出应用程序异常，但是如果同一拦截器方法在生命周期事件之外插入了业务或超时方法，则可以声明它抛出受控异常，
// 包括java.lang.Exception。
// 如果PostConstruct拦截器方法返回一个值，容器将忽略它。
// 定义在非拦截器类上的方法必须具有以下签名:
// 空白< >()方法
// PostConstruct应用的方法可以是public, protected, package private或private。
// 除了应用程序客户端，该方法绝对不能是静态的。
// 这个方法可能是最终的。
// 如果该方法抛出一个未检查的异常，则该类绝对不能放入服务中，除非EJB可以处理异常，甚至可以从中恢复。
@Documented
@Retention (RUNTIME)
@Target(METHOD)
public @interface PostConstruct {
}
